// @ts-nocheck
import axios from 'axios'

let envBaseConfig = {}
if (import.meta.env) {
    // env = process.env.parsed.NODE_ENV;
    envBaseConfig = import.meta.env
}

const service = axios.create({
    baseURL: envBaseConfig.MODE === 'development' ? envBaseConfig.VITE_APP_CONTEXT_PATH : "http://39.98.69.65:7001",
    timeout: 50000
})
// http request 拦截器
service.interceptors.request.use(
    (config) => {
        // 处理逻辑  token 等等
        // config.headers.Authorization = store.state.token
        return config
    },
    (error) => {
        return Promise.reject(error)
    }
)

// http response 拦截器
service.interceptors.response.use(
    (response) => {
        return response.data
    },
    (error) => {
        if (error.response.status === 401) {
            // 无效的 token
        }
        return Promise.reject(error)
    }
)


export default service
